package com.skyworthclub.competition.config.async;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;

import java.lang.reflect.Method;

/**
 * @author li
 * @version 1.0
 * @since 18-10-20 下午11:00
 * 异步任务错误处理器
 **/
public class CustomAsyncUncaughtExceptionHandler implements AsyncUncaughtExceptionHandler {

    private Logger logger = LoggerFactory.getLogger(CustomAsyncUncaughtExceptionHandler.class);

    @Override
    public void handleUncaughtException(Throwable ex, Method method, Object... params) {
        if (logger.isErrorEnabled()) {
            logger.error("异步任务执行出错： " + method.toString() + "-----异常信息： " + ex.getMessage());
        }
    }
}
